﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Apps.Model.Attendance;
using EzDesk.Apps.ServiceImpl.Attendance.Repositories.Interface;
using EzDesk.Apps.ServiceImpl.Repositories.Mock;

namespace EzDesk.Apps.UnitTest
{

    public class Mock_LeaveInfoRepository :
        Mock_Repository<LeaveInfo>, ILeaveInfoRepository
    {

        public List<LeaveInfo> GetLeaveInfoList(
            DateTime? startTime, DateTime? endTime,
            DateTime? createTimeStart,
            DateTime? createTimeEnd,
            Guid? userId,
            bool? isAudited = null,
            bool? isAgreed = null
            )
        {
            var query = innerStorage.GetAll();

            if (startTime.HasValue)
            {
                query = query.Where(p => p.StartTime >= startTime);
            }

            if (endTime.HasValue)
            {
                query = query.Where(p => p.EndTime <= endTime);
            }

            if (createTimeStart.HasValue)
            {
                query = query.Where(p => p.CreateTime >= createTimeStart);
            }

            if (createTimeEnd.HasValue)
            {
                query = query.Where(p => p.CreateTime <= createTimeEnd);
            }

            if (userId.HasValue)
            {
                query = query.Where(p => p.UserId == userId.GetValueOrDefault());
            }

            if (isAudited.HasValue)
            {
                query = query.Where(p => p.IsAudited == isAudited.GetValueOrDefault());

                if (isAgreed.HasValue)
                {
                    query = query.Where(p => p.IsAgreed == isAgreed.GetValueOrDefault());
                }
            }

            return query.ToList();
        }

    }
}
